import { defineConfig, dynamicImport } from 'umi';

import pageRoutes from './router.config';
import alias from './alias';
import theme from './theme';
import qiankun from './qiankun';

import master from './environments/master';
import dev from './environments/dev';
import test from './environments/test';
import pre from './environments/pre';
import online from './environments/online';

var define = dev;
var environment = process.env.NODE_ENV_HUANJING || '本地环境';
if (environment == 'dev') define = dev;
if (environment == 'test') define = test;
if (environment == 'pre') define = pre;
if (environment == 'online') define = online;

console.log('--------------------------------------------');
console.log(`--------------当前环境是${environment}----------------`);
console.log('--------------------------------------------');
console.log(define);

export default defineConfig({
  // 设置编译模式
  nodeModulesTransform: {
    type: 'none',
    exclude: [],
  },

  // 静态化 一个路由文件对应一个html文件 (为了百度爬虫以及谷歌爬虫)
  exportStatic: {},

  //按需加载
  dynamicImport: {},

  // dva
  dva: {},

  // antd
  antd: {},

  //路由配置
  routes: pageRoutes,

  // 国际化配置
  locale: {
    antd: true, // 是否启用antd的<LocaleProvider />  ------由之前的enbale改为 antd
    default: 'zh-CN', //默认语言 zh-CN
    baseNavigator: true, //为true时，用navigator.language的值作为默认语言
    baseSeparator: '-', //语言之间的分隔符
  },

  //多环境配置
  define: define,

  //别名文件的指向
  alias: alias,

  // less变量
  theme: theme,

  //缓存穿透
  hash: true,

  // 配置需要兼容的浏览器最低版本
  targets: {
    ie: 11,
  },

  // // 服务端渲染
  // ssr: {
  //   devServerRender: false,
  // },
  // //服务端渲染地址配置
  // publicPath: '/dist/',

  // 配置微前端
  qiankun: qiankun,
});
